package com.atguigu.lease.web.admin.service.impl;

import com.atguigu.lease.model.enums.ItemType;
import com.atguigu.lease.web.admin.mapper.GraphInfoMapper;
import com.atguigu.lease.web.admin.vo.graph.GraphVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.GraphInfo;
import com.atguigu.lease.web.admin.service.GraphInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liubo
 * @description 针对表【graph_info(图片信息表)】的数据库操作Service实现
 * @createDate 2023-07-24 15:48:00
 */
@Service
public class GraphInfoServiceImpl extends ServiceImpl<GraphInfoMapper, GraphInfo>
        implements GraphInfoService {

    @Override
    public List<GraphVo> getRoomGraph(Long id) {
        //进行表查询
        List<GraphInfo> list = super.list(new LambdaQueryWrapper<GraphInfo>().eq(GraphInfo::getItemId, id).eq(GraphInfo::getItemType, ItemType.ROOM));
        List<GraphVo> list1 = list.stream().map(
                        info -> {
                            GraphVo vo = new GraphVo();
                            vo.setName(info.getName());
                            vo.setUrl(info.getUrl());
                            return vo;
                        })
                .collect(Collectors.toList());
        return list1;
    }
}




